package com.jt.tenant.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jt.tenant.R;
import com.jt.tenant.app.JTApplication;
import com.jt.tenant.conn.GetIntegralList;

import java.util.List;

/**
 * Created by Administrator on 2016/4/7.
 */
public class IntegralInfoAdapter extends BaseAdapter {

    private Context context;

    private List<GetIntegralList.IntegralList> list;

    public IntegralInfoAdapter(Context context, List<GetIntegralList.IntegralList> list) {

        this.context = context;

        this.list = list;

    }

    @Override
    public int getCount() {

        return list.size();

    }

    @Override
    public Object getItem(int position) {

        return list.get(position);

    }

    @Override
    public long getItemId(int position) {

        return position;

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;

        if (convertView == null) {

            convertView = View.inflate(context, R.layout.item_integral_detail, null);

            JTApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);

            holder = new ViewHolder();

            holder.date = (TextView) convertView.findViewById(R.id.integral_item_date);

            holder.item = (TextView) convertView.findViewById(R.id.integral_item_item);

            holder.score = (TextView) convertView.findViewById(R.id.integral_item_score);

            convertView.setTag(holder);

        } else {

            holder = (ViewHolder) convertView.getTag();

        }
        holder.date.setText(list.get(position).date);
        holder.item.setText(list.get(position).describe);
        holder.score.setText(list.get(position).score);

        return convertView;

    }

    class ViewHolder {
        private TextView date;
        private TextView item;
        private TextView score;

    }
}
